﻿Imports System.Data.OleDb


Public Class VideoPlay
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim sql3 As String = "INSERT INTO Video_Views_Stats (VideoID,DateViewed,TimeViewed) VALUES (@f1,@f2,@f3)"
        Dim conn3 As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)

        conn3.Open()

        Dim cmd3 As OleDbCommand = New OleDbCommand(sql3, conn3)

        cmd3.Parameters.AddWithValue("@f1", Request.Params("id"))
        cmd3.Parameters.AddWithValue("@f2", Now.Date.ToString("dd/MM/yyyy"))
        cmd3.Parameters.AddWithValue("@f3", DateTime.Now.ToString("t"))

        cmd3.ExecuteNonQuery()
        conn3.Close()
        cmd3.Dispose()
        conn3.Dispose()



        Dim sql4 As String = "SELECT * FROM VideoView WHERE VideoID=@f20"

        Dim conn4 As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
        conn4.Open()

        Dim cmd4 As OleDbCommand = New OleDbCommand(sql4, conn4)

        cmd4.Parameters.AddWithValue("@f20", Request.Params("id"))

        Dim datareader2 = cmd4.ExecuteReader()


        datareader2.Read()

        If Not IsDBNull(datareader2("CountOfID")) Then lblTotalViews.Text = datareader2("CountOfID")



        Dim sql2 As String = "SELECT * FROM VideoLikesQuery WHERE VideoID=@f20"

        Dim conn2 As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
        conn2.Open()

        Dim cmd2 As OleDbCommand = New OleDbCommand(sql2, conn2)

        cmd2.Parameters.AddWithValue("@f20", Request.Params("id"))

        Dim datareader = cmd2.ExecuteReader()


        datareader.Read()

        If Not IsDBNull(datareader("CountOfID")) Then lblTotalCounts.Text = datareader("CountOfID")
    End Sub


End Class